from twisted.internet import reactor
from twisted.web import static, server, script
-from xen.util.ip import _readline, _readlines
-
class Daemon:
"""The xend daemon.
"""
return 0
# Read the pid of the previous invocation and search active process list.
pid = open(PID_FILE, 'r').read()
- lines = _readlines(os.popen('ps ' + pid + ' 2>/dev/null'))
+ lines = os.popen('ps ' + pid + ' 2>/dev/null').readlines()
for line in lines:
if re.search('^ *' + pid + '.+xensv', line):
if not kill:
from xen.xend.XendLogging import log
-from xen.util.ip import _readline, _readlines
-
def expand_dev_name(name):
if not name:
return name
def mount_mode(name):
mode = None
name = expand_dev_name(name)
- lines = _readlines(os.popen('mount 2>/dev/null'))
+ lines = os.popen('mount 2>/dev/null').readlines()
exp = re.compile('^' + name + ' .*[\(,]r(?P<mode>[ow])[,\)]')
for line in lines:
pm = exp.match(line)
import struct
import errno
-def _readlines(fd):
- """Version of readlines safe against EINTR.
- """
- import errno
-
- lines = []
- while 1:
- try:
- line = fd.readline()
- except IOError, ex:
- if ex.errno == errno.EINTR:
- continue
- else:
- raise
- if line == '': break
- lines.append(line)
- return lines
-
-def _readline(fd):
- """Version of readline safe against EINTR.
- """
- while 1:
- try:
- return fd.readline()
- except IOError, ex:
- if ex.errno == errno.EINTR:
- continue
- else:
- raise
-
##### Networking-related functions
def get_defaultroute():
fd = os.popen('/sbin/ip route list 2>/dev/null')
- for line in fd.xreadlines():
+ for line in fd.readlines():
m = re.search('^default via ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) dev ([^ ]*)',
line)
if m:
if not dev:
return
fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
- for line in fd.xreadlines():
+ for line in fd.readlines():
m = re.search( '^\s+inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
line )
if m:
if not dev:
return
fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
- for line in fd.xreadlines():
+ for line in fd.readlines():
m = re.search( '^.+Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
line )
if m:
if not dev:
return
fd = os.popen( '/sbin/route -n' )
- for line in fd.xreadlines():
+ for line in fd.readlines():
m = re.search( '^\S+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' +
'\s+\S+\s+\S*G.*' + dev + '.*', line )
if m:
from xen.xend import XendRoot
-from xen.util.ip import _readline, _readlines
-
xroot = XendRoot.instance()
"""Where network control scripts live."""
import xen.lowlevel.xc; xc = xen.lowlevel.xc.new()
import xen.util.ip
-from xen.util.ip import _readline, _readlines
from xen.xend.server import channel, controller
from xen.util.blkif import blkdev_uname_to_file
import random
import md5
-from xen.util.ip import _readline, _readlines
-
# Extract from HTML4 spec.
## The following example illustrates "multipart/form-data"
## encoding. Suppose we have the following form:
out.write('"\r\n')
out.write('Content-Type: application/octet-stream\r\n')
out.write('\r\n')
- for l in _readlines(v):
+ for l in v.readlines():
out.write(l)
else:
out.write('Content-Disposition: form-data; name="')
from xen.xend import XendRoot
from xen.xend.XendLogging import log
-from xen.util.ip import _readline, _readlines
-
import channel
import controller
import event
"""
running = 0
if pid:
- lines = _readlines(os.popen('ps %d 2>/dev/null' % pid))
+ lines = os.popen('ps %d 2>/dev/null' % pid).readlines()
exp = '^ *%d.+%s' % (pid, name)
for line in lines:
if re.search(exp, line):
import errno
import string
from StringIO import StringIO
-from xen.util.ip import _readline, _readlines
__all__ = [
"mime_type",
"""
pin = Parser()
while 1:
- buf = _readline(io)
+ buf = io.readline()
pin.input(buf)
if len(buf) == 0:
break